package com.jjsj.mall.shop.service.impl;

import com.jjsj.mall.shop.entity.YoshopUserAddress;
import com.jjsj.mall.shop.mapper.YoshopUserAddressMapper;
import com.jjsj.mall.shop.service.IYoshopUserAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户地址Service业务层处理
 *
 * @author www.joolun.com
 * @date 2022-10-24
 */
@Service
public class YoshopUserAddressServiceImpl implements IYoshopUserAddressService {
    @Autowired
    private YoshopUserAddressMapper yoshopUserAddressMapper;

    /**
     * 查询用户地址
     *
     * @param addressId 用户地址ID
     * @return 用户地址
     */
    @Override
    public YoshopUserAddress selectYoshopUserAddressById(String addressId) {
        return yoshopUserAddressMapper.selectYoshopUserAddressById(addressId);
    }

    /**
     * 查询用户地址列表
     *
     * @param yoshopUserAddress 用户地址
     * @return 用户地址
     */
    @Override
//    @DataSource(value = DataSourceType.SLAVE)
    public List<YoshopUserAddress> selectYoshopUserAddressList(YoshopUserAddress yoshopUserAddress) {
        return yoshopUserAddressMapper.selectYoshopUserAddressList(yoshopUserAddress);
    }

    /**
     * 新增用户地址
     *
     * @param yoshopUserAddress 用户地址
     * @return 结果
     */
    @Override
    public int insertYoshopUserAddress(YoshopUserAddress yoshopUserAddress) {
        return yoshopUserAddressMapper.insertYoshopUserAddress(yoshopUserAddress);
    }

    /**
     * 修改用户地址
     *
     * @param yoshopUserAddress 用户地址
     * @return 结果
     */
    @Override
    public int updateYoshopUserAddress(YoshopUserAddress yoshopUserAddress) {
        return yoshopUserAddressMapper.updateYoshopUserAddress(yoshopUserAddress);
    }

    /**
     * 批量删除用户地址
     *
     * @param addressIds 需要删除的用户地址ID
     * @return 结果
     */
    @Override
    public int deleteYoshopUserAddressByIds(String[] addressIds) {
        return yoshopUserAddressMapper.deleteYoshopUserAddressByIds(addressIds);
    }

    /**
     * 删除用户地址信息
     *
     * @param addressId 用户地址ID
     * @return 结果
     */
    @Override
    public int deleteYoshopUserAddressById(String addressId) {
        return yoshopUserAddressMapper.deleteYoshopUserAddressById(addressId);
    }
}
